package com.guoxue.dao.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.guoxue.dao.IInventoryDao;
import com.guoxue.domain.InventoryVo;
@Repository
public class InventoryDaoImpl extends BaseDaoImpl<InventoryVo> implements IInventoryDao {

	@Override
	public void saveInventory(InventoryVo inventoryVo) {
		saveOrUpdate(inventoryVo);
	}

	@Override
	public List<InventoryVo> getInventoryList(Integer uid) {
		return find("FROM InventoryVo i WHERE i.uid= ? AND i.sysflag = 0", new Object[] {uid});
	}

	@Override
	public Long getInventoryTotal(int uid) {
		return count("SELECT count(*) FROM InventoryVo i WHERE i.uid = ? AND i.sysflag = 0",new Object[] {uid});
	}

	@Override
	public InventoryVo getInventory(int uid) {
		return get("FROM InventoryVo i WHERE i.uid = ? AND i.sysflag = 0", new Object[] {uid});
	}

	@Override
	public InventoryVo getInventoryByUidAndGoodsId(Integer uid, Integer goodsId) {
		return get("FROM InventoryVo i WHERE i.uid = ? AND i.goodsId = ? AND i.sysflag = 0", new Object[] {uid,goodsId});
	}

	@Override
	public List<InventoryVo> getInventoryGoodsTypeList(Integer uid, Integer typeId) {
		return find("FROM InventoryVo i WHERE i.uid= ? AND i.typeId = ? AND i.sysflag = 0", new Object[] {uid,typeId});
	}

	@Override
	public List<InventoryVo> getCurrentTimeData(String d) {
		return find("FROM InventoryVo i WHERE i.outOfTime = ? AND i.sysflag = 0", new Object[] {d});
	}

}
